﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using WL.Dal;
using WL.Model;

namespace WL.Bll
{
    class DataService
    {
        internal static void SaveByDataTable(System.Data.DataTable dt, Model.Table t)
        {
            DataDal.saveByDT2(dt, t);
        }

        
        public static DataTable getData(Table table, string key)
        {
            if (key.Equals(""))
            {
                return DataDal.getDatas(table.name);
            }
            return DataDal.getDatas(table, key);
        }


        internal static bool delById(Table t, string sid)
        {
            try {
                int id = Convert.ToInt32(sid);
                return DataDal.deleteById(t, id)>0;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        internal static bool update(Table t, int dataid, string values)
        {
            return DataDal.update(t,dataid,values)>0;
            
        }
    }
}
